home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld: Complete Mac Interactive
/
Macworld Complete Mac Interactive CD)(1994).iso
/
The Best of BMUG
/
Utilities
/
Text and Speech
/
Alpha.5.76
/
Tcl
/
SystemCode
/
templates.tcl
< prev
next >
Wrap
Text File
|
1994-03-08
|
2KB
|
79 lines
#=============================================================================
# Template editing, just an example. To use, load this file, hit
# control-i, and a for template will appear. Consecutive control-j's
# will step you though various fields of the for statement.
#=============================================================================
# C 'for' template
menu -n Templates {
"forTemplate"
"whileTemplate"
"(-"
"/\\nextStop"
"(-"
"findTag…"
"createTagFile"}
insertMenu Templates
proc forTemplate {} {
indentLine
set pos [getPos]
set indent [indentString $pos]
set str1 "for (\;\;)\r"
set str2 "\{\r"
set str3 "\t\r"
set str4 "\}\r"
insertText $str1 $indent $str2 $indent $str3 $indent $str4 $indent
set len [string length $indent]
createTMark stop1 [expr $pos+5]
createTMark stop2 [expr $pos+6]
createTMark stop3 [expr $pos+7]
set temp4 [expr { $pos + [string length $str1] + [string length $str2] +
[string length $str3] + 2 * $len - 1}]
createTMark stop4 $temp4
createTMark stop5 [expr { $temp4 + 2 * [string length $str4] + $len}]
global stopRing
set stopRing "stop1 stop2 stop3 stop4 stop5"
gotoTMark stop1
bind 'j' <z> nextStop
}
proc whileTemplate {} {
indentLine
set pos [getPos]
set indent [indentString $pos]
set str1 "while ()\r"
set str2 "\{\r"
set str3 "\t\r"
set str4 "\}\r"
insertText $str1 $indent $str2 $indent $str3 $indent $str4 $indent
set len [string length $indent]
createTMark stop1 [expr $pos+7]
set temp [expr { $pos + [string length $str1] + [string length $str2] +
[string length $str3] + 2 * $len - 1}]
createTMark stop2 $temp
createTMark stop3 [expr { $temp + 2 * [string length $str4] + $len}]
global stopRing
set stopRing "stop1 stop2 stop3"
gotoTMark stop1
bind 'j' <z> nextStop
}
proc nextStop {} {
global stopRing
set first [lindex $stopRing 0]
set stopRing [lreplace $stopRing 0 0]
set stopRing [lappend stopRing $first]
gotoTMark [lindex $stopRing 0]
}